<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css">
		
	</head>
	<body>
		<form class="layui-form" id="addDepot" style="margin: 15px;">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">仓库名称：</label>
					<div class="layui-input-block">
					  <input type="text" name="depotName" lay-verify="required" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">负&nbsp;责&nbsp;人：</label>
					<div class="layui-input-block">
					  <select name="empId" id="empName" lay-filter="empName">
					  </select>
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">联系电话：</label>
					<div class="layui-input-block">
					  <input type="text" name="depotPhone" lay-verify="required|phone" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">仓库转态：</label>
					<div class="layui-input-block">
					  <select name="depotState">
						<option value="1">正常状态</option>
						<option value="0">禁用状态</option>
					  </select>
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">仓库地址：</label>
					<div class="layui-input-block">
					  <input style="width: 400px;" type="text" name="depotAdress" lay-verify="required" class="layui-input">
					</div>					
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：</label>
					<div class="layui-input-block">
					  <input style="width: 400px;" type="text" name="depotComment" class="layui-input">
					</div>					
				</div>
			</div>
			<div class="layui-form-item" style="text-align: center;">
				<div class="layui-inline">
					<label class="layui-form-label">默认仓库</label>
					<div class="layui-input-block">
					  <input type="checkbox" name="depotDefault" lay-skin="primary" >
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">POS仓库</label>
					<div class="layui-input-block">
					   <input type="checkbox" name="" lay-skin="primary">
					</div>
				</div>
			</div>
			<div class="layui-form-item" style="text-align: center;">
				<div class="layui-inline">
					<button type="button" class="layui-btn" lay-submit lay-filter="saveBtn">保存</button>
				</div>
				<div class="layui-inline">
					<button type="reset" class="layui-btn">重&nbsp;&nbsp;置</button>
				</div>
			</div>
		</form>
		<script src="../../layui/layui.js" charset="utf-8"></script>
		<script>
			layui.use(['form', 'table', 'layer'], function(){
				var tree = layui.tree
				    ,layer = layui.layer
					,table = layui.table
					,form = layui.form
					,$ = layui.jquery;

				//查询负责人姓名
                $.ajax({
                    url: '/searchEmpName',
                    dataType: 'json',
                    type: 'get',
                    success: function (data) {
                        $.each(data, function (index, item) {
                            // 下拉菜单里添加元素
                            $('select[name=empId]').append(new Option(item.empName,item.empId));
                        });
                        //重新渲染 固定写法
                        layui.form.render("select");
                    }
                });
				//页面刷新
                form.on('submit(saveBtn)',function (obj) {
                    var depotInfo = $('#addDepot').serialize();
                    $.ajax({
						url:'/insertDepotInfo?'+depotInfo,
                        success: function(obj){
                            parent.layui.table.reload('custId');
                            //关闭弹窗
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        }
					})
                    
                })
			})
		</script>
	</body>
</html>
